/*
 * Copyright (C) 2010 Rodion Volkov (volkov.rodion@gmail.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.rchik.divermate;

import android.graphics.Color;
import android.graphics.drawable.LevelListDrawable;
import android.view.View;
import android.widget.ImageView;

public class LevelIndicator {
	
	static final int[] levelColors = {
		Color.argb(218, 0, 153, 59),
		Color.argb(218, 19, 160, 55),
		Color.argb(218, 37, 168, 51),
		Color.argb(218, 55, 176, 47),
		Color.argb(218, 79, 187, 41),
		Color.argb(218, 99, 196, 37),
		Color.argb(218, 126, 207, 31),
		Color.argb(218, 147, 216, 26),
		Color.argb(218, 170, 224, 21),
		Color.argb(218, 194, 232, 15),
		Color.argb(218, 212, 236, 11),
		Color.argb(218, 229, 236, 7),
		Color.argb(218, 243, 236, 3),
		Color.argb(218, 253, 236, 0),
		Color.argb(218, 254, 229, 0),
		Color.argb(218, 254, 219, 0),
		Color.argb(218, 254, 202, 0),
		Color.argb(218, 254, 184, 0),
		Color.argb(218, 251, 163, 0),
		Color.argb(218, 244, 141, 0),
		Color.argb(218, 236, 119, 0),
		Color.argb(218, 227, 96, 0),
		Color.argb(218, 219, 74, 0),
		Color.argb(218, 210, 53, 0),
		Color.argb(218, 202, 34, 0),
		Color.argb(218, 196, 18, 0),
		Color.argb(218, 190, 0, 0)
	};
	
	public static void IndicateLevel(View view, int level)
	{		
		if ( level != -1)
		{
			((LevelListDrawable)((ImageView)view.findViewById(R.id.NitroLevelImageView)).getDrawable()).setLevel(level+1);
			view.findViewById(R.id.BackgroundImageView).setBackgroundColor(levelColors[level+1]);
		}
		else
		{
			((LevelListDrawable)((ImageView)view.findViewById(R.id.NitroLevelImageView)).getDrawable()).setLevel(0);
			view.findViewById(R.id.BackgroundImageView).setBackgroundColor(levelColors[0]);
		}
	}

}
